﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>身份证办理进度查询</title>
    <meta charset='UTF-8'>
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no,email=no" name="format-detection" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
    <link href="../css/alipay/alipay.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/amui-demo_files/toast.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/button.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/amui-demo_files/dialog.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/amui-demo_files/button-group.css" type="text/css" rel="stylesheet" />
    <link href="../css/main.css" type="text/css" rel="stylesheet" />
    <link href="../css/dialog.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../js/extensions/base.js"></script>
    <script type="text/javascript" src="../css/alipay/amui-demo_files/amui.js"></script>
    <style>
        .ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d {
            padding: 10px 0 10px 0;
            text-align: center;
        }

            .ui-block-a img, .ui-block-b img, .ui-block-c img, .ui-block-d img {
                width: 43%;
                padding-top: 10%;
            }

        .am-button {
            padding-LEFT: 15PX;
        }
         .am-list:not([am-version]){padding: 0px;}
    </style>
    <script type="text/javascript">
        $(function(){
            /*$("#dialogbut").click(function(){
             $(".mask").show();
             $(".demo-content").show();
             });*/

            $(".am-dialog-button").click(function(){
                $(".mask").hide();
                $(".demo-content").hide();
            });

        })
    </script>
</head>
<body>
<div class="mask" style="display: none;"></div>
<div class="demo-content"  style="display: none;">
    <div class="demo-mobile">
        <div class="am-dialog show" style="z-index: 10001;">
            <div class="am-dialog-wrap">
                <div class="am-dialog-body">
                    <p id="warn" class="am-dialog-brief"></p>
                </div>
                <div class="am-dialog-footer">
                    <a class="am-dialog-button">取消</a>
                    <a class="am-dialog-button">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
    <div data-role="page">
        <div data-role="content" style="background-color:#EFEFF4;padding-top:15PX">
            <div class="am-list" am-mode="flat form">
                <div class="am-list-body">
                    <div class="am-search-input">
                        <div class="am-list-item am-input-autoclear">
                            <div class="am-list-label">身份证号码</div>
                            <div class="am-list-control">
                                <input type="text" id="inputIDCard" placeholder="身份证号码" value="">
                                <input type="hidden" placeholder="" value="">
                            </div>
                            <div class="am-list-clear"><i class="am-icon-clear am-icon" am-mode="clear"></i></div>
                        </div>
                        </div>
                        <div style="padding-left:15px;padding-right:15px;margin-top:15PX;">
                            <button id="searchButton" type="button" class="am-button" am-mode="blue disabled">查询</button>
                        </div>
                    </div>
            </div>
        </div>
        <div id="fuwu" style="display: block;font-family:STHeitiSC  ;font-size: 12px; margin-bottom: 15px; margin-left: 0px; width: 100%; text-align: center; position: absolute; bottom: 0px;z-index:-1;">
            <div class="am-agreement am-ft-gray am-ft-sm">
                <p>
                    本服务由吉林省公安厅<br />江苏欧索软件有限公司提供支持
                </p>
            </div>
        </div>
    </div>

    <script>
        $(function () {
            window.setInterval("checkButtonState()", 200);

            $("#searchButton").click(function () {
                var idCard = $("#inputIDCard").val();
                if (idCard) {
                    if (CheckIDCard()) {

                        Search();
                    } else {
                       // $("#inputIDCard").val("");
                        $("#searchButton").attr("am-mode", "blue disabled");
                    }
                }
            });
        });
        function checkButtonState() {
            if ($("#inputIDCard").val())
                $("#searchButton").attr("am-mode", "blue");
            else
                $("#searchButton").attr("am-mode", "blue disabled");
        }

        function CheckIDCard() {
            var idCard = $("#inputIDCard").val();
            if (idCard.length == 18) {
                var regIdCard = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
                if (regIdCard.test(idCard)) {
                    var idCardWi = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); //将前17位加权因子保存在数组里
                    var idCardY = new Array(1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2);
                    var idCardWiSum = 0;
                    for (var i = 0; i < 17; i++) {
                        idCardWiSum += idCard.substring(i, i + 1) * idCardWi[i];
                    }
                    var idCardMod = idCardWiSum % 11;
                    var idCardLast = idCard.substring(17);
                    if (idCardMod == 2) {
                        if (idCardLast == "X" || idCardLast == "x") {
                            return true;
                        }
                        else {
                            $("#warn").html("身份证号码错误！");
                            $(".mask").show();
                            $(".demo-content").show();
                        }
                    }
                    else {
                        //用计算出的验证码与最后一位身份证号码匹配，如果一致，说明通过，否则是无效的身份证号码
                        if (idCardLast == idCardY[idCardMod]) {
                            return true;
                        }
                        else {
                            $("#warn").html("身份证号码错误！");
                            $(".mask").show();
                            $(".demo-content").show();
                        }
                    }
                }
            }
            else if (idCard.length == 15) {
                isIDCard1 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
                if (isIDCard1.test(idCard)) {
                    return true;
                }
                else {
                    $("#warn").html("身份证号码输入错误！");
                    $(".mask").show();
                    $(".demo-content").show();
                }
            }
            else {
                $("#warn").html("身份证格式不正确！");
                $(".mask").show();
                $(".demo-content").show();
            }
        }

        function Search()
        {
            var idcard = $("#inputIDCard").val();
            var url = "../../../api/query/progress/idcard";
            $.ajax(url, {
                type: "post",
                timeout: 6000,
                data: {"idCard": idcard},
                success: function (data) {
                    if (data.succ == true) {
                        window.location.href = 'RegisterIdCardResult.html?idcard=' + idcard;
                    } else {
                        $("#warn").html("未查到相关信息，请确认后再重试！");
                        $(".mask").show();
                        $(".demo-content").show();
                    }
                },
                error: function (xhr) {
                },
                complete: function () {
                }
            });
        }
    </script>
</body>
</html>
